package com.itheima.tlias84.servrce.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.tlias84.dto.*;
import com.itheima.tlias84.mapper.ClazzMapper;
import com.itheima.tlias84.mapper.EmpMapper;
import com.itheima.tlias84.po.DeleteClazzParam;
import com.itheima.tlias84.po.InsertClazzParam;
import com.itheima.tlias84.po.SelectClazzPageParam;
import com.itheima.tlias84.po.UpdateClazzParam;
import com.itheima.tlias84.servrce.ClazzService;
import com.itheima.tlias84.servrce.EmpService;
import com.itheima.tlias84.utils.ResultUtil;
import com.itheima.tlias84.vo.ClazzPageVO;
import com.itheima.tlias84.vo.pageVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Resource
    ClazzMapper clazzMapper;
    @Resource
    EmpMapper empMapper;
    @Override
    public int insertClazz(InsertClazzParam insertClazzParam) {

        return clazzMapper.insertClazz(insertClazzParam);
    }

    @Override
    public  ResultUtil selectClazzDetailDTO(SelectClazzPageParam param) {
        //计算分页
       // param.setPage((param.getPage()-1),param.getPageSize());
        Page<Object> page = PageHelper.startPage(param.getPage(), param.getPageSize());
        List<SelectClazzDetailDTO> dtos = clazzMapper.selectClazzDetailDTO(param);
        pageVO pageVO = new pageVO();
        //返回的总记录数
        pageVO.setTotal(page.getTotal());
        pageVO.setRows(dtos);
        return ResultUtil.success(pageVO);
    }

    @Override
    public int deleteClazzById(Integer id) {
        int i = clazzMapper.deleteClazzById(id);
        return i;
    }

    @Override
    public int updateClazzById(UpdateClazzParam updateClazzParam) {
        int i = clazzMapper.updateClazzById(updateClazzParam);
        return i;
    }

    @Override
    public SelectClazzIDDTO selectClazzIDDTO(Integer id) {
        SelectClazzIDDTO selectClazzIDDTO = clazzMapper.selectClazzIDDTO(id);
        return selectClazzIDDTO;
    }


    @Override
    public List<SelectClazzDTO> selectClazzList() {
        List<SelectClazzDTO> selectClazzDTOS = clazzMapper.selectClazzList();
        return selectClazzDTOS;
    }




}
